package com.lee.lease.web.app.custom.config;
import com.lee.lease.common.interceptor.LoginInterceptor;
import com.lee.lease.web.app.custom.converter.StringToBaseEnumFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName: AppLoginInterceptorConfiguration
 * Package: com.lee.lease.web.app.custom.config
 * Description:
 */
@Configuration
public class AppConfiguration implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor interceptor;
    @Autowired
    private StringToBaseEnumFactory converterFactory;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
                .addPathPatterns("/app/**")
                .excludePathPatterns("/app/login/**");

    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverterFactory(converterFactory);
    }
}
